﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/4/2009
 * Time: 1:14 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using PilotFish.Model;

namespace PilotFish.Gui
{
	/// <summary>
	/// Description of AllergyForm.
	/// </summary>
	public partial class AllergyForm : BaseForm
	{
		public AllergyForm()  : this(new Allergy())
		{
			
		}
		
		public AllergyForm(Allergy a)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = a;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			Allergy a = Model as Allergy;
			textBoxName.Text = a.Name;
			checkBoxInactive.Checked = a.Inactive;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			Allergy a = Model as Allergy;
			a.Name = textBoxName.Text;
			a.Inactive = checkBoxInactive.Checked;
			SessionFacade.SaveOrUpdateAllergy(a);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
